package com.lzw.mapper.dormitoryAdmin;

import org.apache.ibatis.annotations.*;

import java.util.Map;

@Mapper
public interface DormitoryAdminMapper {
    @Select("SELECT admin_id FROM dormitorymanagement.dormitoryadmin WHERE username = #{username} AND password = #{password}")
    Integer checkCredentials(@Param("username") String username, @Param("password") String password);

    @Select("SELECT admin_id, name, username, gender, phone, email, dormitory_building_id FROM dormitorymanagement.dormitoryadmin WHERE username = #{username} AND password = #{password}")
    Map<String, Object> getAdminInfo(@Param("username") String username, @Param("password") String password);

    @Select("SELECT admin_id, name, username, gender, phone, email, dormitory_building_id FROM dormitorymanagement.dormitoryadmin WHERE admin_id = #{adminId}")
    Map<String, Object> getAdminInfoById(@Param("adminId") Integer adminId);

    @Update("UPDATE dormitorymanagement.dormitoryadmin SET name = #{name}, gender = #{gender}, phone = #{phone}, email = #{email} WHERE admin_id = #{adminId}")
    int updateAdminInfo(@Param("adminId") Integer adminId, @Param("name") String name,
                        @Param("gender") String gender, @Param("phone") String phone,
                        @Param("email") String email);
}
